home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
emulation
/
onetouchmac
/
source
/
onetouchmac.c
Wrap
C/C++ Source or Header
|
1999-05-14
|
3KB
|
87 lines
// program:OneTouchMac V1.0
// Author:TIPHAINE Julien
// Last updated the: 30/04/1999
// Description: Alow to execute a diferent startup-sequence, given in arguments,
// by pressing LMB or RMB. This prog ONLY WORK WITH AMIGA MOUSE PORT
#include <stdio.h>
#include <string.h>
#include <exec/types.h>
#include <hardware/custom.h>
#include <hardware/cia.h>
#define LEFT_BUTTON 1
#define MIDDLE_BUTTON 2
#define RIGHT_BUTTON 4
#define PORT1 1
extern struct Custom far custom;
extern struct CIA far ciaa;
/* here the Mouse function declaration, see below */
UBYTE Mouse(UBYTE port, BYTE *delta_x, BYTE *delta_y);
int main(int argc, char **argv)
{
UBYTE Reponse;
BYTE dx=0, dy=0;
char Commande[100]= "execute "; /* Just for executing files given in arguments */
/* Check if some arguments have been typed */
if (argc < 2)
{ printf("Syntaxe is: OneTouchMac <Startup File 1> [<Startup File 2>]");
printf("\nTry Again ! :)");
}
Reponse = Mouse (PORT1, &dx, &dy); /* get the Mouse button witch is pressed */
/* First condition: Execute the first argument file if LMB is pressed */
if (Reponse == LEFT_BUTTON)
{ strcat(Commande, argv[1], argv[2]);
system(Commande);
return 1; /* Alow to stop Startup-sequence execution, that's why the first Startup-sequence comande mist be "FAILAT 1" */
}
/* second condition: Execute the second argument file if RMB is pressed */
if (argc == 3) /* Test if a second Startup file has been typed */
{ if (Reponse == RIGHT_BUTTON)
{ strcat(Commande, argv[1], argv[3]);
system(Commande);
return 1;
}
}
return 0; /* quit program if no mouse button is pressed */
}
/***************** Mouse Function ********************/
/* Return values 1,2 or 4 if left, Middle or Right */
/* Mouse button have been pressed. the Middle mouse */
/* button is not yet used in this version... */
/* I know is not well programed at all, but sorry */
/* I have copied/pasted this function 'cause I didn't*/
/* Know how to do this without opening a window... */
/* Sorry, but hey, I'm a Beginner ! */
/*****************************************************/
UBYTE Mouse(UBYTE port, BYTE *delta_x, BYTE *delta_y)
{
UBYTE data = 0;
UWORD joy, pot;
custom.potgo = 0xFF00;
pot = custom.potinp;
joy = custom.joy0dat;
data += !( ciaa.ciapra & 0x0040 ) ? LEFT_BUTTON : 0;
data += !( pot & 0x0100 ) ? MIDDLE_BUTTON : 0;
data += !( pot & 0x0400 ) ? RIGHT_BUTTON : 0;
return( data );
}